package com.atguigu.c_enum;

public class Demo1 {
    public static void main(String[] args) {
        //类方法
        //获取枚举类中的所有枚举对象并存入到数组中
        Light[] lights = Light.values();
        for (Light light : lights) {
            System.out.println("light = " + light);
        }

        //String --> Enum
        String name = "RED";

        //对字符串的内容进行解析
        Light light = Light.valueOf(name);
        System.out.println("light = " + light); //RED

        //对象方法
        System.out.println("light.ordinal() = " + light.ordinal());//枚举项在枚举类中的编号

        //Enum --> String
        String name1 = light.name();
        System.out.println("name1 = " + name1);
        String name2 = light.toString();
        System.out.println("name2 = " + name2);
    }
}
